﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Trade.Library.Common
{
    /// <summary>
    /// excel导出格式化类
    /// </summary>
    public class EnumExportFormat
    {
        /// <summary>
        /// excel导出格式化enum
        /// </summary>
        [Serializable]
        public enum TYPEFormat
        {
            字符串类型 = 0,
            TF图片,
            是否转换,
            企业类型转换,
            来源转换,
        }
        /// <summary>
        /// image格式化
        /// </summary>
        /// <param name="i"></param>
        /// <returns></returns>
        public static string IMAGEFormat(object i)
        {
            if (i.ToString() == "0") { return "~/newui/images/no.png"; }
            else if (i.ToString() == "1") { return "~/newui/images/ok.png"; }
            else { return ""; }
        }
        /// <summary>
        /// 其他数据格式化
        /// </summary>
        /// <param name="type"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public static string OFormat(TYPEFormat type,object i)
        {
            switch (type)
            {
                case TYPEFormat.是否转换:
                    {
                        if (i.ToString() == "1" || i.ToString()=="True") { return "是"; }
                        else if (i.ToString() == "0" || i.ToString() == "False") { return "否"; }
                        else { return ""; }
                    }
                case TYPEFormat.企业类型转换:
                    {
                        if (i.ToString() == "0") { return "生产企业"; }
                        else { return "配送企业"; }
                    }
                case TYPEFormat.来源转换:
                    {
                        if (i.ToString() == "0") { return "华招"; }
                        else if (i.ToString() == "1") { return "平台"; }
                        else { return "新增"; }
                    }
                default:
                    return i.ToString();
            }
        }
    }
}
